package asteroids.expressions;

import java.util.Map;

import asteroids.Ship;
import asteroids.types.*;

public class CosExpression extends MathUnaryExpression {

	public CosExpression(int line, int column, Expression expression) {
		super(line, column, expression);
	}
	
	@Override
	public Type evaluate(Ship ship, Map<String, Type> globals) {
		if(ship != null)
			return new DoubleType(Math.cos(((DoubleType) getExpression().evaluate(ship, globals)).getValue()));
		else
			return new DoubleType();
	}
	
	@Override
	public String toString() {
		return "cos(" + getExpression().toString() + ")" ;
	}

}
